#include "bullet.h"

Bullet::Bullet(Point position, Direction direction)
{
  position_ = position;
  position_.y = 0.8;
  switch(direction) {
  case NORTH:
    movement_ = Vector(0.25, 0, 0);
    break;
  case EAST:
    movement_ = Vector(0, 0, 0.25);
    break;
  case SOUTH:
    movement_ = Vector(-0.25, 0, 0);
    break;
  case WEST:
    movement_ = Vector(0, 0, -0.25);
    break;
  default:
    break;
  }
}

Point Bullet::GetPosition()
{
  return position_;
}

int Bullet::GetX()
{
  return position_.x > 0 ? position_.x : -1 ;
}

int Bullet::GetZ()
{
  return position_.z > 0 ? position_.z : -1;
}

void Bullet::Update()
{
  position_ += movement_;
}

void Bullet::Render()
{
  glColor3f(1, 1, 1);
  glMaterialfv(GL_FRONT, GL_DIFFUSE, (GLfloat[]) {0.1, 0.1, 0.1, 1});
  glMaterialfv(GL_FRONT, GL_SPECULAR, (GLfloat[]) {0.1, 0.1, 0.1, 1});
  glMaterialfv(GL_FRONT, GL_AMBIENT, (GLfloat[]) {0.1, 0.1, 0.1, 1.0});
  glMaterialfv(GL_FRONT, GL_SHININESS, (GLfloat[]) {0});
  Point ini(position_.x - 0.1, position_.y - 0.1, position_.z - 0.1);
  Point end(position_.x + 0.1, position_.y + 0.1, position_.z + 0.1);
  Box::Render(ini, end);
}
